home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / compuserve-file-archive / 12 C64 Telecom / PORTPR.ASM < prev    next >
Encoding:
Assembly Source File  |  2019-04-13  |  6.6 KB  |  464 lines

  1. .nolist
  2. .origin $1000
  3. screen = $0400
  4. putc   = $ffd2
  5. plot   = $fff0
  6. stop   = $ffe1
  7. setlfs = $ffba
  8. setnam = $ffbd
  9. open   = $ffc0
  10. chkin  = $ffc6
  11. getin  = $ffe4
  12. chkout = $ffc9
  13. close  = $ffc3
  14. clrchn = $ffcc
  15. rsstat = $0297
  16. readst = $ffb7
  17. listen = $ffb1
  18. line   = $dd01  ;controls DTR, etc.
  19. second = $ff93  ;for printer
  20. ciout  = $ffa8
  21. unlsn  = $ffae
  22. minutes= $dc0a  ;stored by TOD clock
  23. ptr    = $fb    ;zp pointer for printing
  24. bufptr = $fd    ;zp pointer for buffer
  25. ctrlreg= $0293  ;data and stop bits (40)
  26. cmdreg = $0294  ;parity and handsk (97)
  27.  
  28. jmp BEGINNING
  29. carriage:  .byte 0
  30. ystore: .byte 0
  31. pry:    .byte 0
  32. prname: .byte 0,0
  33. fname:  .byte 40, 97
  34. ;com1:e,7,1  x-line handshake
  35. array: .blkb 128
  36. BEGINNING:
  37. jsr SETUP
  38. jsr SETARRAY
  39. jsr OPEN232
  40. NEXTLINE:
  41. ldx #12
  42. ldy #0
  43. clc
  44. jsr plot    ;move cursor
  45. lda line           
  46. ora #2     ;raise DTR. Ready to receive
  47. sta line
  48. WAIT:
  49. jsr getin   ;grab anything in the port
  50. cmp #13
  51. beq DROP    ;drop DTR, that is
  52. cmp #0
  53. bne FOUND.ONE
  54. lda rsstat
  55. sta screen+216
  56. jsr  $ffea  ;PRG says you need this one
  57. jsr stop    ;to scan the stop key
  58. bne WAIT
  59. rts         ;break if STOP pressed
  60. FOUND.ONE:  ;ok, then translate it
  61. jmp TRANSLATE ;into petscii
  62. OK:
  63. ldy ystore  ;get last value of y
  64. sta (bufptr),y  ;put it in buffer
  65. sta screen-1       ;temporary of course
  66. iny
  67. sty ystore
  68. jsr putc    ;print it to the screen
  69. lda screen-1    ; putc alters Accumul.
  70. nop
  71. .print * getstat  
  72. GETSTAT:
  73. ldx carriage
  74. cpx #$ff    ;$ff is my EOL marker
  75. bne WAIT
  76. jsr DOUBLECHECK ;anything else received
  77. jsr clrchn      ;clear channels
  78. jsr PLINE       ;print line
  79. jsr clrchn
  80. jsr REOPEN232   ;setup 232
  81. jsr CLRLN       ;clear the last line
  82. jmp NEXTLINE    ;off the screen
  83.  
  84. TRANSLATE:
  85. and #127    ;allowing for a few weird
  86. tax
  87. sec
  88. sbc #31     ;array offset by 32
  89. nop
  90. bcc FEED
  91. tay
  92. dey
  93. lda array,y ;loading in the petscii 
  94. TRANOK: jmp OK
  95. TRAEND: jmp WAIT ;and go back
  96. FEED:
  97. txa
  98. cmp #12
  99. beq DROP  
  100. cmp #13
  101. bne TRAEND  ;12 and 13 are the only 
  102. DROP:tax    ;valid characters <32       
  103. lda line    ;
  104. and #253    ;drop RTS
  105. sta line
  106. lda #$ff    ;put EOL mark
  107. sta carriage
  108. lda #122        ;checkmark
  109. sta screen + 282
  110. lda #32
  111. sta screen + 202
  112. txa
  113. jmp OK
  114.  
  115. .print * pline
  116. PLINE:
  117. lda #122        ;move checkmark
  118. sta screen + 221
  119. lda #32
  120. sta screen + 301
  121. nop
  122. jsr OPENPR
  123. ldy #0
  124. sty pry
  125. LOOP = *
  126. ldy pry
  127. lda (bufptr),y  ;get char from buffer
  128. iny
  129. sty pry
  130. cmp #$ff        ;until EOL
  131. beq RAUS
  132. jsr ciout       ;print it
  133. jsr readst
  134. sta screen+233
  135. jmp LOOP
  136. RAUS: jsr UNLYSNA
  137. rts
  138.  
  139. SETARRAY:   ;elements cmb, subscrps IBM
  140. ldx #32     ;first element in array
  141. ldy #0      ;first subscript
  142. Loop = *
  143. txa         ;easier to address
  144. sta array,y ;put it at top of code array
  145. iny
  146. inx         ;add one
  147. cpx #65     ;translation changes at 65
  148. bne Loop
  149. nop
  150. ldx #97 ;upper case, x=65,
  151. Loop = *
  152. txa         ;easier to address
  153. sta array,y ;put it at top of code array
  154. iny         ;y was inc'ed coming in.
  155. inx         ;add one
  156. cpx #123    ;translation changes at 123
  157. bne Loop
  158. nop
  159. lda #91     ;a few irregulars here
  160. sta array, y    ;left bracket
  161. iny         ;y was = 91 too
  162. lda #47     ;backslash
  163. sta array,y
  164. iny
  165. lda  #93    ;right bracket
  166. sta array,y
  167. iny
  168. lda #94     ;caret
  169. sta array,y
  170. iny
  171. lda #45     ;minus sign 
  172. sta array,y
  173. iny
  174. lda #39
  175. sta array,y ;reverse accent mark
  176. iny         ;now y=97-32
  177. ldx #65
  178. Loop = *
  179. txa         ;easier to address
  180. sta array,y ;put it at top of code array
  181. iny
  182. inx         ;add one
  183. cpx #91     ;translation ends at 90
  184. bne Loop
  185. nop
  186. rts         ;go back whence ye came 
  187. nop
  188.  
  189. .print * unlysna
  190. UNLYSNA:        ;unlisten the printer
  191. nop
  192. lda #32         ;move checkmark
  193. sta screen+221
  194. lda #122
  195. sta screen+301
  196. jsr unlsn       ;kernal routine
  197. jsr readst
  198. sta screen+313
  199. lda #4
  200. jsr close
  201. sta screen+314
  202. jsr readst
  203. sta screen+315
  204. rts
  205.  
  206.  
  207. OPEN232:
  208. lda #$70        ;beginning of my buffer
  209. sta bufptr+1    ;$7000 stored in $fd,fe
  210. lda #$00
  211. sta bufptr
  212. lda #$28    ;decimal 40
  213. sta ctrlreg ;7 data, 1 stop
  214. lda #$61    ;even parity, x-line
  215. sta cmdreg  ;decimal 97
  216. lda #0      ;length of filename
  217. .print * loading fname
  218. .print fname
  219. .print fname+1
  220. ldx fname  ;LB fname address
  221. ldy fname+1;HB fname address
  222. jsr setnam  ;page 298
  223. lda #05     ;lf number for RS232
  224. ldx #02     ;device#2
  225. ldy #03     ;channel #3
  226. jsr setlfs  ;page 297
  227. jsr open    ;page 289
  228. sta screen+214
  229. jsr readst
  230. sta screen+215
  231. REOPEN232:
  232. .print * reopen
  233. ldx #05     ;lf number
  234. jsr chkin   ;initialize for input
  235. sta screen+254
  236. ldy #0
  237. sty ystore
  238. sty carriage
  239. lda #32         ;move checkmark
  240. sta screen+282
  241. lda #122
  242. sta screen+202
  243. rts
  244.  
  245. OPENPR:
  246. lda #32         ;move checkmark
  247. sta screen+301
  248. lda #122
  249. sta screen+221
  250. ldx prname
  251. ldy prname+1
  252. jsr setnam      ;logical filename
  253. lda #04
  254. ldx #04
  255. ldy #07
  256. jsr setlfs      ;device, file, SA #'s
  257. jsr open        ;open it
  258. sta screen+233
  259. jsr readst
  260. ldx #4
  261. jsr chkout      ;initialize LF#4
  262. sta screen+273
  263. jsr readst
  264. sta screen+274
  265. lda #0
  266. sta ptr
  267. lda #$70
  268. sta ptr+1       ;bottom of buffer
  269. rts
  270.  
  271. DOUBLECHECK:    ;make sure buffer is 0
  272. jsr getin
  273. sta carriage
  274. jsr readst
  275. and #8
  276. cmp #8
  277. beq D.OUT
  278. lda carriage
  279. and #127
  280. tax
  281. sec
  282. sbc#31          ;just like TRANSLATE
  283. bcc SMALL
  284. tay
  285. dey
  286. lda array,y
  287. jmp D.OK
  288. SMALL:
  289. txa
  290. cmp #12
  291. beq D.OK
  292. cmp #13
  293. bne DOUBLECHECK
  294. D.OK:
  295. ldy ystore
  296. sta (bufptr),y
  297. iny
  298. sty ystore
  299. jmp DOUBLECHECK
  300. D.OUT:
  301. ldy ystore
  302. lda #$ff
  303. sta (bufptr),y
  304. rts
  305.  
  306. pstat:.asciz /Printer Status/
  307. rstat:.asciz /RS 232 Status/
  308. und:.byte 120
  309. ostat:.asciz /Chan Open: /
  310. istat:.asciz /Chan Init: /
  311. cstat:.asciz /Chan Close:/
  312. lstat:.asciz /Last Line Received:/
  313. cord:.byte 0,0,0
  314. astore:.byte 0
  315. SETUP:
  316. lda #32
  317. ldy #0
  318. LOOP = *        ;clearscreen
  319. sta screen,y
  320. sta screen+$0100,y
  321. sta screen+$0200,y
  322. sta screen+$02e7,y
  323. iny
  324. bne LOOP    ;these loop just set up the
  325. lda #<rstat ;screen initially.
  326. sta ptr     ;nothing fancy, just a lot
  327. lda #>rstat ;of code._
  328. sta ptr+1
  329. lda #0
  330. sta cord
  331. ldy #3
  332. ldx #2
  333. jsr PUTS
  334.  
  335. lda #<pstat
  336. sta ptr
  337. lda #>pstat
  338. sta ptr+1
  339. lda #0
  340. sta cord
  341. ldy #22
  342. ldx #2
  343. jsr PUTS
  344.  
  345. lda #13
  346. sta cord
  347. ldy #3
  348. ldx #3
  349. lda #184 
  350. sta astore
  351. jsr UNDLN
  352. lda #14
  353. sta cord
  354. ldy #22
  355. ldx #3
  356. jsr UNDLN
  357.  
  358. lda #<ostat
  359. sta ptr
  360. lda #>ostat
  361. sta ptr+1
  362. lda #0
  363. sta cord
  364. ldy #3
  365. ldx #5
  366. jsr PUTS
  367. lda #0
  368. sta cord
  369. ldy #22
  370. ldx #5
  371. jsr PUTS
  372.  
  373. lda #<istat
  374. sta ptr
  375. lda #>istat
  376. sta ptr+1
  377. lda #0
  378. sta cord
  379. ldy #3
  380. ldx #6
  381. jsr PUTS
  382. lda #0
  383. sta cord
  384. ldy #22
  385. ldx #6
  386. jsr PUTS
  387.  
  388. lda #<cstat
  389. sta ptr
  390. lda #>cstat
  391. sta ptr+1
  392. lda #0
  393. sta cord
  394. ldy #3
  395. ldx #7
  396. jsr PUTS
  397. lda #0
  398. sta cord
  399. ldy #22
  400. ldx #7
  401. jsr PUTS
  402.  
  403. lda #<lstat
  404. sta ptr
  405. lda #>lstat
  406. sta ptr+1
  407. lda #0
  408. sta cord
  409. ldy #3
  410. ldx #10
  411. jsr PUTS
  412.  
  413. rts     
  414. UNDLN:
  415. clc
  416. jsr plot
  417. ldy cord
  418. LOOP =*
  419. lda astore
  420. jsr putc
  421. ldy cord
  422. dey
  423. sty cord
  424. bne LOOP
  425. rts
  426.  
  427. PUTS:
  428. clc
  429. jsr plot
  430. ldy cord
  431. lda (ptr),y
  432. LOOP =*
  433. jsr putc
  434. ldy cord
  435. iny
  436. sty cord
  437. lda (ptr),y
  438. bne LOOP
  439. rts
  440. ldy #22
  441. ldx #2
  442. clc
  443. jsr plot
  444. ldy #0
  445. sty cord
  446. lda pstat
  447. LOOP =*
  448. jsr putc
  449. ldy cord
  450. iny
  451. sty cord
  452. lda pstat,y
  453. bne LOOP
  454.  
  455. CLRLN:
  456. ldy #80
  457. lda #32
  458. loop =*
  459. sta screen +480, y 
  460. dey
  461. bne loop
  462. rts
  463.  
  464.